package com.ssy.lingxi.enhance.constant;

import java.util.Arrays;

/**
 * 通用布尔枚举 - enum
 * @author fhj
 * @date 2020/10/29
 * @version 2.0.0
 */
public enum CommonBooleanEnum {

    NO(0, "否"),
    YES(1, "是");

    private final int code;
    private final String message;

    CommonBooleanEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(CommonBooleanEnum.values()).filter(e -> e.getCode() == code).findFirst().orElse(NO).getMessage();
    }
}
